package com.ljx.threadTest.threadEnum;

/**
 * @author <a href="mailto:wf2311@163.com">wf2311</a>
 * @since 2022/6/10 15:50.
 */
public class Init {
    public static final String APP_CODE_NAME = "app.global.int.code";
    public static final String MODULE_CODE_NAME = "module.global.int.code";

    /**
     * 默认的应用编码
     */
    public static final int DEFAULT_APP_CODE;
    /**
     * 默认的模块编码
     */
    public static final int DEFAULT_MODULE_CODE;

    static {
        String a = getEnv(APP_CODE_NAME);
        int da = 0;
        try {
            if (a != null) {
                da = Integer.parseInt(a);
            }
        } catch (Exception ignore) {
        }

        DEFAULT_APP_CODE = da;

        String m = getEnv(MODULE_CODE_NAME);
        int dm = 0;
        try {
            if (m != null) {
                dm = Integer.parseInt(m);
            }
        } catch (Exception ignore) {
        }
        DEFAULT_MODULE_CODE = dm;
    }

    private static String getEnv(String key) {
        String v = System.getProperty(key);
        if (v == null) {
            v = System.getenv(key);
        }
        return v;
    }

}
